package com.example.demo.concurrent.BlockingQueueTest;

import com.example.demo.BlockingQueue.BlockingQueueSingleLock;
import lombok.extern.slf4j.Slf4j;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-03-16
 * Time: 15:11
 */
@Slf4j(topic = "c.MainTest")
public class MainTest {
    public static void main(String[] args) throws InterruptedException {
        BlockingQueueSingleLock<String> queue = new BlockingQueueSingleLock<String>(3);
        Thread t1 = new Thread(() -> {
            log.debug("begin");
            try {
                queue.offer("任务1");
                System.out.println(queue);
                queue.offer("任务2");
                System.out.println(queue);
                queue.offer("任务3");
                System.out.println(queue);
                queue.offer("任务4",5000);
                System.out.println(queue);
            } catch (InterruptedException e) {
                throw new RuntimeException("");
            }
            log.debug("end");
        });
        t1.start();
        Thread.sleep(2000);
        queue.poll();
    }
}